import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Official/Home.vue";
import index from "../views/index.vue";
import Case from "../views/Shopping/Case.vue";
import Partner from "../views/Shopping/Partner.vue";
import website from "../views/Official/website.vue";
import project from "../views/Official/Project.vue";
import projectDetails from "../views/Official/project/projectDetails.vue";
import furnitureCases from "../views/Official/project/furnitureCases.vue";
import designer from "../views/Official/project/designer.vue";
import construction from "../views/Official/project/construction.vue";
import designerTeam from "../views/Official/designerTeam.vue";
import aboutUs from "../views/Official/aboutUs.vue";
import details from "../views/Official/details.vue";
import mallCatalog from "../views/Shopping/MallCatalog.vue";



Vue.use(VueRouter);
//push  避免跳转同一个路由报错出现
const VueRouterPush = VueRouter.prototype.push 
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    children: [
      {
        path: "/",
        name: "website",
        component: website,
        meta: {
          title: "优粤家官网"
        },
      },
      // 项目案例
      {
        path: "/project",
        name: "project",
        component: project,
        children: [
          {
            path: "/",
            name: "projectDetails",
            component: projectDetails,
            meta: {
              title: "项目案例"
            },
          },
          {
            path: "/furnitureCases",
            name: "furnitureCases",
            component: furnitureCases
          },
          {
            path: "/designer",
            name: "designer",
            component: designer
          },
          {
            path: "/construction",
            name: "construction",
            component: construction
          },
        ]
      },
      // 设计师团队
      {
        path: "/designerTeam",
        name: "designerTeam",
        component: designerTeam,
        meta: {
          title: "设计师团队"
        },
      },
      // 关于我们
      {
        path: "/aboutUs",
        name: "aboutUs",
        component: aboutUs,
        meta: {
          title: "关于我们"
        },
      },
      // 项目详情
      {
        path: "/details",
        name: "details",
        component: details,
        meta: {
          title: "项目详情"
        },
      },
    ],
  },
  
  // 商城的两个页面
  {
    path: "/index",
    name: "index",
    component: index,
    children: [
      {
        path: "/Case",
        name: "Case",
        component: Case,
        meta: {
          title: "案例"
        },
      },
      {
        path: "/Partner",
        name: "Partner",
        component: Partner,
        meta: {
          title: "合作商"
        },
      },
      {
        path: "/mallCatalog",
        name: "mallCatalog",
        component: mallCatalog,
        meta: {
          title: "商城目录"
        },
      },
    ]
  },
  
];

const router = new VueRouter({
  // mode: "history",
  base: process.env.BASE_URL,
  // base: '',
  routes,
  scrollBehavior () {
    // return 期望滚动到哪个的位置
    return { x: 0, y: 0 }
  }
});

export default router;
